<?php
namespace App\traits ;
use Validator;

trait ValidateTrait
{
    protected  $_validateErrors = null ;
    public function validate($data = []){
        $validate = Validator::make($data,$this->rules());
        if($validate->fails()){
            $this->_validateErrors = $validate->errors() ;
            return false ;
        }
        return true ;
    }

    public function rules(){
        return [] ;
    }

    public function getErrors(){
        return $this->_validateErrors ;
    }
}